﻿using System;
using System.Collections.Generic;

using System.Text;

namespace Rance.Battle
{
    class 骑兵AI : AI
    {
        public override AIResult Excute(角色 角色, 队伍状况 队伍状况, AI技能MGT 技能mgt)
        {
            AIResult result = new AIResult();
            var 技能list = 技能mgt.GetBy行动点(2);
            if (技能list.Count > 0)
            {
                int rate = 0;

                switch (角色.行动点)
                { 
                    case 1:
                        break;
                    case 2:
                        rate = 60;
                        break;
                    case 3:
                        rate = 85;
                        break;
                    default:
                        rate = 100;
                        break;
                }

                bool hit = false;
                if (rate == 100)
                    hit = true;
                else if (rate > 0)
                    hit = 队伍状况.战场.AI乱数表.Hit(rate);

                if (hit)
                {
                    if (技能list.Count == 1)
                    {
                        result.Action = 技能list[0].Name;
                        result.TargetList = 技能list[0].TargetList[0].List;

                        return result;
                    }
                    else if (技能list.Count > 1)
                    {
                        var value = 队伍状况.战场.AI乱数表.Random(0, 技能list.Count);

                        result.Action = 技能list[value].Name;
                        result.TargetList = 技能list[value].TargetList[0].List;

                        return result;
                    }
                }
            }


            //选择冲锋
            var 冲锋 = 技能mgt.Get("冲锋");
            result.Action = 冲锋.Name;
            result.TargetList = 冲锋.TargetList[0].List;

            return result;
            
        }

        private static 骑兵AI instance = new 骑兵AI();
        public static 骑兵AI GetInstance()
        {
            return instance;
        }
    }
}
